package com.font.web.zhongyao;



import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.api.ApiController;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.font.bean.Docker;
import com.font.bean.result.Result;
import com.font.service.DockerService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;

/**
 * (Docker)表控制层
 *
 * @author makejava
 * @since 2023-07-19 13:52:41
 */
@RestController
@RequestMapping("docker")
public class DockerController extends ApiController {
    /**
     * 服务对象
     */
    @Resource
    private DockerService dockerService;

    @RequestMapping("list")
    public Result prescriptionList(
            @RequestParam(value = "docName",required = false) String docName ,
            @RequestParam(value = "currentPage",required = false,defaultValue = "1") Integer currentPage,
            @RequestParam(value = "pageSize",required = false,defaultValue = "8") Integer pageSize

    ){


        QueryWrapper<Docker> queryWrapper = new QueryWrapper<Docker>()
                .like(StrUtil.isNotBlank(docName), "doc_name", docName);

        IPage<Docker> page = dockerService.page(new Page<Docker>(currentPage,pageSize),queryWrapper);
        int pages = page.getRecords().size();
        long pages2 = page.getTotal();
        HashMap<String, Object> map = new HashMap<>();
        map.put("page",page);
        map.put("pages",pages);
        return Result.success(map);
    }
}

